#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

int count = 0;
void Bubblesort(int arr[], int sz)
{
	int i = 0;
	int flsg = 0;

	for (i = 0; i < sz; i++)
	{
		
		for (int j = 0; j < sz - 1 - i; j++)
		{
			count++;
			if(arr[j]>arr[j+1])
			{ 
				int temp = arr[j];
				arr[j] = arr[j+1];
				arr[j+1] = temp;
				flsg = 1;
			}
			
		}
		if (flsg == 0)
		{
			break;
		}

		
	}
	
}

int main()
{	
	int arr1[10] = { 3,2,5,4,6,8,9,0,7,1, };
	int sz = sizeof(arr1) / sizeof(arr1[0]);
	Bubblesort(arr1, sz);

	for (int i = 0; i < 10; i++)
	{
		printf("%d ", arr1[i]);
		
	}
	printf("\n");
	printf("count = %d\n", count);

	return 0;
}